package com.cyt.web.controller.work.kwmanagement;

import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.StringUtils;
import com.cyt.sys.util.EasyPoiUtil;
import com.cyt.work.kwmanagement.model.vo.*;
import com.cyt.work.kwmanagement.service.KwTeacherSettingService;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import com.cyt.wx.model.vo.WxEducationUserVo;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * 考务教师表-考务教师表控制层
 *
 * @author han jun
 * @date 2019-11-26 11:26:26
 */
@RestController
public class KwTeacherSettingController extends BaseController {

    @Resource
    private KwTeacherSettingService kwTeacherSettingService;
    
    /**
     * 统一跳转
     *
     * @param model 数据模型
     * @return Model
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @RequestMapping("/work/kwmanagement/kwteachersetting/*")
    public Model goPage(Model model) {
        return model;
    }

    /**
     * 分页查询
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/findPage", method = RequestMethod.POST)
    public ReturnResult findPage(KwTeacherSettingVo kwTeacherSettingVo, int page, int limit) {
        return kwTeacherSettingService.findPage(kwTeacherSettingVo, page, limit);
    }

    /**
     * 分页查询
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/findVoPage", method = RequestMethod.POST)
    public ReturnResult findVoPage(KwTeacherSettingVo kwTeacherSettingVo, int page, int limit) {
        return kwTeacherSettingService.findVoPage(kwTeacherSettingVo, page, limit);
    }

    /**
     * list查询
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "list查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/findList", method = RequestMethod.POST)
    public ReturnResult findList(KwTeacherSettingVo kwTeacherSettingVo) {
        return new ReturnResult(kwTeacherSettingService.findList(kwTeacherSettingVo));
    }

    /**
     * list查询
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "list查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/findVoList", method = RequestMethod.POST)
    public ReturnResult findVoList(KwTeacherSettingVo kwTeacherSettingVo) {
        return new ReturnResult(kwTeacherSettingService.findVoList(kwTeacherSettingVo));
    }

    /**
     * 单个对象查询
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/findOne", method = RequestMethod.POST)
    public ReturnResult findOne(KwTeacherSettingVo kwTeacherSettingVo) {
        return new ReturnResult(kwTeacherSettingService.findOne(kwTeacherSettingVo));
    }

    /**
     * 单个对象查询
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/findVoOne", method = RequestMethod.POST)
    public ReturnResult findVoOne(KwTeacherSettingVo kwTeacherSettingVo) {
        return new ReturnResult(kwTeacherSettingService.findVoOne(kwTeacherSettingVo));
    }

    /**
     * 跳转添加或编辑界面
     *
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "跳转添加或编辑界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/getEdit", method = RequestMethod.GET)
    public ModelAndView getEdit(KwTeacherSettingVo kwTeacherSettingVo) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwteachersetting/kwTeacherSettingEdit");
        if (StringUtils.isNotBlank(kwTeacherSettingVo.getId())) {
            view.addObject(kwTeacherSettingService.findVoOne(kwTeacherSettingVo));
        }
        return view;
    }

    /**
     * 保存或更新
     *
     * @param request 请求对象
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "保存或更新对象", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/addOrUpdate", method = RequestMethod.POST)
    public ReturnResult addOrUpdate(HttpServletRequest request, KwTeacherSettingVo kwTeacherSettingVo,KwKcSettingVo kwKcSettingVo) {
        return kwTeacherSettingService.addOrUpdate(kwTeacherSettingVo,kwKcSettingVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件逻辑删除
     *
     * @param request 请求对象
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "逻辑删除对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/remove", method = RequestMethod.GET)
    public ReturnResult remove(HttpServletRequest request, KwTeacherSettingVo kwTeacherSettingVo) {
        return kwTeacherSettingService.remove(kwTeacherSettingVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件物理删除
     *
     * @param request 请求对象
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "物理对象对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/delete", method = RequestMethod.GET)
    public ReturnResult delete(HttpServletRequest request, KwTeacherSettingVo kwTeacherSettingVo) {
        return kwTeacherSettingService.delete(kwTeacherSettingVo, acceptCurrentUser(request));
    }


    /**
     * 获取巡监考老师详情
     *
     * @param request 请求对象
     * @param kwTeacherSettingVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "获取巡监考老师详情", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/getKwTeacherSettingMap", method = RequestMethod.POST)
    public ReturnResult getKwTeacherSettingMap(HttpServletRequest request, KwTeacherSettingVo kwTeacherSettingVo) {
        return kwTeacherSettingService.getKwTeacherSettingMapById(kwTeacherSettingVo);
    }



    /**
     * 获取所有监考老师的分页
     *

     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/getAllTeacherJkNumer", method = RequestMethod.POST)
    public ReturnResult getAllTeacherJkNumer( int page, int limit) {
        return kwTeacherSettingService.getAllTeacherJkNumer( page, limit);
    }

    /**
     * 导出巡考老师模板
     * @param response
     * @author hanjun
     * @date 2019/9/3 13:43
     */
    @RequestMapping(value = "/work/kwmanagement/kwstudentmessage/exportxkTea")
    public void exportExcel(HttpServletResponse response) {
        List<KwTeacherExportVo> list = kwTeacherSettingService.getAllExportXKteacher();
        // 导出操作
        EasyPoiUtil.exportExcel(list, "老师巡考情况统计", "老师巡考情况统计", KwTeacherExportVo.class, "老师巡考情况统计.xls", response);
    }

    /**
     * 导出监考老师模板
     * @param response
     * @author hanjun
     * @date 2019/9/3 13:43
     */
    @RequestMapping(value = "/work/kwmanagement/kwstudentmessage/exportjkTea")
    public void exportjkTea(HttpServletResponse response) {
        List<KwTeacherJkStaticVo> list = kwTeacherSettingService.getAllExportJKteacher();
        // 导出操作
        EasyPoiUtil.exportExcel(list, "老师监考情况统计", "老师监考情况统计", KwTeacherJkStaticVo.class, "老师监考情况统计.xls", response);
    }




    /**
     * 获取所有巡考老师的分页
     *

     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:26:26
     */
    @BaseLog(module = "考务教师表", classz = "考务教师表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/getAllTeacherXkNumer", method = RequestMethod.POST)
    public ReturnResult getAllTeacherXkNumer( int page, int limit) {
        return kwTeacherSettingService.getAllTeacherXkNumer( page, limit);
    }

    /**
     *获取某一场考试的所有监巡考老师
     *
     * @param keyWord 搜索关键字
     * @return ReturnResult
     * @author Jun Han
     * @date 2019/9/26 17:18
     */
    @BaseLog(module = "学校通用用户模块", classz = "基础用户", methods = "获取某一场考试的所有监巡考老师", businessType = BusinessType.IMPORT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/getAllTeacherListjxk", method = RequestMethod.POST)
    public ReturnResult getAllTeacherListjxk(String keyWord,String type,String ksId) {
        WxEducationUserVo wxEducationUserVo = new WxEducationUserVo();
        wxEducationUserVo.setUserType("2");
        wxEducationUserVo.setName(keyWord);
        ReturnResult returnResult = kwTeacherSettingService.selectorjxk(wxEducationUserVo,type,ksId);
        return returnResult;
    }


    /**
     *获取某一场考试某一个教师的所有座位号
     *
     * @return ReturnResult
     * @author Jun Han
     * @date 2019/9/26 17:18
     */
    @BaseLog(module = "学校通用用户模块", classz = "基础用户", methods = "获取某一场考试的所有监巡考老师", businessType = BusinessType.IMPORT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/getAllStudentSeatNum", method = RequestMethod.POST)
    public ReturnResult getAllStudentSeatNum(String kcId,String ksId) {
        ReturnResult returnResult = kwTeacherSettingService.selectorStudentSeatNum(kcId,ksId);
        return returnResult;
    }


    /**
     * 保存更新座位号
     * @return ReturnResult
     * @author Jun Han
     * @date 2019/9/26 17:18
     */
    @BaseLog(module = "学校通用用户模块", classz = "基础用户", methods = "保存更新座位号", businessType = BusinessType.IMPORT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachersetting/addupdateSeatNum", method = RequestMethod.POST)
    public ReturnResult addupdateSeatNum(HttpServletRequest request,String newId,String id) {
        ReturnResult returnResult = kwTeacherSettingService.addUpdateStudentSeatNum(newId,id,acceptCurrentUser(request));
        return returnResult;
    }





}